package net.oschina.app.fragment.explore;

import android.content.Intent;

import net.oschina.app.adapter.explore.FriendsRircleAdapter;
import net.oschina.app.base.BaseListAdapter;
import net.oschina.app.base.BaseListFragment;
import net.oschina.app.bean2.ActiveBean;
import net.oschina.app.bean2.ExploreFriendBean;
import net.oschina.app.protocol.AccessProtocol;
import net.oschina.app.protocol.explore.FriendsCircleProtocol;
import net.oschina.app.ui.activity.explore.FriendsCricleDetilActivity;

import java.util.List;

/**
 * Created by 张运湘 on 2017/1/17.
 */

public class FriendsCirlceFragment extends BaseListFragment {

    private FriendsCircleProtocol mFriendsCircleProtocol;
    private FriendsRircleAdapter mFriendsRircleAdapter;

    @Override
    protected List parseData(Object body) {
        List<ActiveBean> activies = ((ExploreFriendBean) body).getActivies();
        return activies;
    }

    @Override
    protected AccessProtocol getProtocol() {
        mFriendsCircleProtocol = new FriendsCircleProtocol();
        return mFriendsCircleProtocol;
    }

    @Override
    protected BaseListAdapter getAdapter() {
        mFriendsRircleAdapter = new FriendsRircleAdapter(getContext());
        setOnItemClick();
        return mFriendsRircleAdapter;
    }
    public void setOnItemClick(){
        mFriendsRircleAdapter.setItemOnclickListener(new FriendsRircleAdapter.setItemOnclickListener() {
            @Override
            public Void toDetilactivity() {
                Intent intent = new Intent(getContext(),FriendsCricleDetilActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
                return null;
            }
        });
    }
}
